import request from './request'

// 获取用户列表
export const getUserList = (params) => {
  return request.get('/user/list', { params })
}

// 获取用户详情
export const getUserDetail = (id) => {
  return request.get(`/user/${id}`)
}

// 创建用户
export const createUser = (data) => {
  return request.post('/user', data)
}

// 更新用户信息
export const updateUser = (id, data) => {
  return request.put(`/user/${id}`, data)
}

// 删除用户
export const deleteUser = (id) => {
  return request.delete(`/user/${id}`)
}

// 批量删除用户
export const batchDeleteUsers = (ids) => {
  return request.delete('/user/batch', { data: { ids } })
}

// 重置用户密码
export const resetPassword = (id, newPassword) => {
  return request.put(`/user/${id}/password`, { newPassword })
}

// 启用/禁用用户
export const toggleUserStatus = (id, status) => {
  return request.put(`/user/${id}/status`, { status })
}

// 获取角色列表
export const getRoleList = () => {
  return request.get('/user/roles')
}

// 分配用户角色
export const assignUserRoles = (userId, roleIds) => {
  return request.put(`/user/${userId}/roles`, { roleIds })
}
